From 23d3defdcdd21cae8728c65ef77eeb72da849191 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 23 Mar 2015 11:49:56 -0700 Subject: [PATCH] Fix printing `Fresh` for crates --- src/cargo/ops/cargo_rustc/job_queue.rs | 61 +++++++++++++++++--------- src/cargo/ops/cargo_rustc/mod.rs | 1 + 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 29c56925e..103726755 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -58,6 +58,7 @@ pub enum Stage { Binaries, LibraryTests, BinaryTests, + End, } type Message = (PackageId, Stage, Freshness, CargoResult<()>); @@ -190,31 +191,44 @@ impl<'a> JobQueue<'a> { } // Print out some nice progress information - // - // This isn't super trivial becuase we don't want to print loads and - // loads of information to the console, but we also want to produce a - // faithful representation of what's happening. This is somewhat nuanced - // as a package can start compiling *very* early on because of custom - // build commands and such. - // - // In general, we try to print "Compiling" for the first nontrivial task - // run for a package, regardless of when that is. We then don't print - // out any more information for a package after we've printed it once. - let print = !self.printed.contains(&pkg.package_id()); - if print && total_fresh == Dirty && running.len() > 0 { - self.printed.insert(pkg.package_id()); - match total_fresh { - Fresh => try!(config.shell().verbose(|c| { - c.status("Fresh", pkg) - })), - Dirty => try!(config.shell().status("Compiling", pkg)) - } - } + try!(self.note_working_on(config, pkg.package_id(), stage, total_fresh, + running.len())); for msg in running.iter() { try!(config.shell().verbose(|c| c.status("Running", msg))); } Ok(()) } + + // This isn't super trivial becuase we don't want to print loads and + // loads of information to the console, but we also want to produce a + // faithful representation of what's happening. This is somewhat nuanced + // as a package can start compiling *very* early on because of custom + // build commands and such. + // + // In general, we try to print "Compiling" for the first nontrivial task + // run for a package, regardless of when that is. We then don't print + // out any more information for a package after we've printed it once. + fn note_working_on(&mut self, config: &Config, pkg: &'a PackageId, + stage: Stage, fresh: Freshness, cmds_run: usize) + -> CargoResult<()> { + if self.printed.contains(&pkg) { return Ok(()) } + + match fresh { + // Any dirty stage which runs at least one command gets printed as + // being a compiled package + Dirty if cmds_run == 0 => {} + Dirty => { + self.printed.insert(pkg); + try!(config.shell().status("Compiling", pkg)); + } + Fresh if stage == Stage::End => { + self.printed.insert(pkg); + try!(config.shell().verbose(|c| c.status("Fresh", pkg))); + } + Fresh => {} + } + Ok(()) + } } impl<'a> Dependency for (&'a PackageId, Stage) { @@ -288,6 +302,13 @@ impl<'a> Dependency for (&'a PackageId, Stage) { base.extend(deps.map(|(id, _)| (id, Stage::Libraries))); base } + + // A marker stage to indicate when a package has entirely finished + // compiling, nothing is actually built as part of this stage. + Stage::End => { + vec![(id, Stage::Binaries), (id, Stage::BinaryTests), + (id, Stage::LibraryTests)] + } } } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index d2ccaeb81..ab670aaf8 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -278,6 +278,7 @@ fn prepare_init<'a, 'b>(cx: &mut Context<'a, 'b>, jobs.queue(pkg, Stage::Binaries); jobs.queue(pkg, Stage::LibraryTests); jobs.queue(pkg, Stage::BinaryTests); + jobs.queue(pkg, Stage::End); // Prepare the fingerprint directory as the first step of building a package let (target1, target2) = fingerprint::prepare_init(cx, pkg, Kind::Target); -- 2.30.2